﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using Newtonsoft.Json;

namespace MQTT.Server.Host.Entity
{
    [JsonObject(MemberSerialization.OptIn)]
    public class DeviceEntity : DependencyObject
    {

        public static readonly DependencyProperty IsOnlineProperty = DependencyProperty.Register(
            "IsOnlineDep", typeof(byte), typeof(DeviceEntity), new PropertyMetadata(default(byte)));

        public byte IsOnlineDep
        {
            get { return (byte) GetValue(IsOnlineProperty); }
            set { SetValue(IsOnlineProperty, value); }
        }

        private byte _isOnLine = 0;
        [JsonProperty]
        public byte IsOnline
        {
            get => _isOnLine;
            set
            {
                _isOnLine = value;
                IsOnlineDep = _isOnLine;
            }
        }

        [JsonProperty]
        public int Id { get; set; }

        [JsonProperty]
        public string Name { get; set; }

        [JsonProperty]
        public List<DataNodeEntity> DataNodes { get; set; }
    }
}
